#include "serverload.h"
#include "ui_serverload.h"

ServerLoad::ServerLoad(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ServerLoad)
{
    ui->setupUi(this);
}

ServerLoad::~ServerLoad()
{
    delete ui;
}

int ServerLoad::getServerNumber()
{
    return serverNumber;
}

void ServerLoad::setServerNumber(int number)
{
    serverNumber = number;
}

void ServerLoad::setServerAddress(const QHostAddress address, quint16 port)
{
    serverAddress = address;
    serverPort = port;
    QString str = "IP: ";
    str.append(serverAddress.toString());
    str.append("  Port: ").append(QString::number(port));
    ui->serverAddress->setText(str);
}

QLabel* ServerLoad::getServerStatus()
{
    return ui->serverStatus;
}

void ServerLoad::setServerStatus(QString str)
{
    ui->serverStatus->setText(str);
}

int ServerLoad::getWorkLoad()
{
    return ui->workLoadBar->value();
}

QHostAddress ServerLoad::getServerAddress()
{
    return serverAddress;
}

quint16 ServerLoad::getServerPort()
{
    return serverPort;
}

void ServerLoad::setAddress(QString str)
{
    ui->serverAddress->setText(str);
}
/* Duplicate
void ServerLoad::setStatus(QString str)
{
    ui->serverStatus->setText(str);
}*/

void ServerLoad::setWorkLoad(int x)
{
    /*
    QPalette pal = ui->workLoadBar->palette();
    if(x < 80) {
        pal.setColor(QPalette::Active, QPalette::Highlight, Qt::green);
        pal.setColor(QPalette::Inactive, QPalette::Highlight, Qt::green);
    } else {
        pal.setColor(QPalette::Active, QPalette::Highlight, Qt::red);
        pal.setColor(QPalette::Inactive, QPalette::Highlight, Qt::red);
    }
    ui->workLoadBar->setPalette(pal);*/
    ui->workLoadBar->setValue(x);
}
